package tgc.edu.fhh.repository;



import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import tgc.edu.fhh.custom.BaseRepository;
import tgc.edu.fhh.entity.Course;
import tgc.edu.fhh.entity.Grade;
import tgc.edu.fhh.entity.Student;
@Repository
public interface GradeRepository extends BaseRepository<Grade, Integer>{

	@Query(value = "from Grade g where g.student.tbclass.id=?1 and g.course.id=?2")
	public List<Grade> findByTbClassIdAndCourseId(Integer bjId, Integer couId);

	@Query(value = "from Grade g where g.student.tbclass.id=?1 and g.student.id=?2")
	public List<Grade> findByTbClassIdAndStudentId(Integer bjId, Integer stuId);

	@Query(value = "from Grade g where g.student.id=?1")
	public List<Grade> findByStudentId(Integer id);
	
	@Query("select distinct t.course from Grade t where t.student.tbclass.id=?1")
	public List<Course> findCourseByTbclassId(Integer bjId);

	@Query("select distinct t.student from Grade t where t.course.id=?1")
	public List<Student> findStudentByCourseId(Integer courseId);


}
